package org.demo.patten.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhuj
 * @date 2025/3/22
 * @apiNote
 */
public class TreeFactory {
    private static final Map<String, TreeType> treePool = new HashMap<>();
    public static TreeType getTreeType(String name, String color, String texture) {
        String key = name + "-" + color + "-" + texture;
        if (!treePool.containsKey(key)) {
            treePool.put(key, new ConcreteTreeType(name, color, texture));
        }
        return treePool.get(key);
    }
    public static int getTotalTypes() {
        return treePool.size();
    }
}
